<template>
  <div id="top">
    <el-row
      style="width:70%;margin: auto;margin-top:2px;margin-bottom:2px;"
      id="topRow"
      ref="top"
    >
      <el-col :span="4">
        <div class="grid-content topCol">
          <el-link @click="goIndex()" target="_blank" class="navigationBarFont">
            首页
          </el-link>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content topCol" topCol>
          <el-link @click="goIndex()" target="_blank" class="navigationBarFont">
            分类
          </el-link>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content topCol">
          <el-link @click="goIndex()" target="_blank" class="navigationBarFont">
            标签
          </el-link>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content topCol">
          <el-link @click="goIndex()" target="_blank" class="navigationBarFont">
            留言
          </el-link>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content topCol">
          <el-link @click="goIndex()" target="_blank" class="navigationBarFont">
            源码
          </el-link>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content topCol">
          <el-link @click="goIndex()" target="_blank" class="navigationBarFont">
            <el-row style="margin:auto;">
              <el-col :span="12">
                <div class="block">
                  <el-avatar :size="37" :src="''">登录</el-avatar>
                </div>
              </el-col>
            </el-row>
          </el-link>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { uploadBuffer, downLoadBuffer } from "./upload/oss";
export default {
  props: {},

  components: {},

  data() {
    return {
      photoUrl: "",
      defaultProfilePhotoName: "profile-photo/default.jpg",
      fits: ["fill", "contain", "cover", "none", "scale-down"],
      scroll: ""
    };
  },

  mounted() {
    window.addEventListener("scroll", this.handleScroll);
    // this.getDefaultProfilePhoto();
  },

  methods: {
    getDefaultProfilePhoto() {
      downLoadBuffer(this.defaultProfilePhotoName).then(res => {
        this.photoUrl = res;
        console.log(res);
      });
    },
    goIndex() {
      this.$router.push({ path: "/" });
    },
    test() {
      let scrollTop = document.documentElement.scrollTop;
      console.log(scrollTop);
    },
    handleScroll() {
      this.scroll =
        document.documentElement.scrollTop || document.body.scrollTop;
      let tp = document.getElementById("top");
      if (this.scroll > 60) {
        tp.style.position = "fixed";
        tp.style.left = "0px";
      } else {
        tp.style.position = "";
      }

      // console.log(tp);
    }
  },

  watch: {},
  destroyed() {
    window.removeEventListener("scrollHeight", this.handleScroll);
  }
};
</script>
<style scoped>
#top {
  height: 49px;
  border-bottom: 1px solid #ced8e3;
  /* position: fixed; */
  background: rgba(253, 253, 253,0.5);
  top: 0;
  right: 0;
  width: 100%;
}
.navigationBarFont {
  font-size: 16px;
  align-content: center;
  height: 100%;
  width: 100px;
  color: white;
}
.topCol {
  height: 45px;
  background: #434e50;
}
.el-row {
  margin-bottom: 20px;
}
.el-col {
  border-radius: 10px;
}
.grid-content {
  border-radius: 20px;
  min-height: 36px;
}
.row-bg {
  padding: 15px 0;
  background-color: #f9fafc;
}
</style>
